//获取url中的参数
function getUrlParam(name, def = false) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
	var r = window.location.search.substr(1).match(reg); //匹配目标参数

	if (r != null) {
		return unescape(r[2]);
	} else {
		return def; //返回参数值
	}
}
function debug() {

	if (getUrlParam('debug', 0) == 1) {
		console.log('debug');
		var script = document.createElement('script');
		script.src = "https://csmbimagae.shop.jzzw-tech.cn/hcyp/app1/eruda.min.js";
		document.body.append(script);
		script.onload = function () { eruda.init(); }
	}
}

$(".jq22-ate-head").css("background", "#ffffff");
var app = {
	getUrlParam: function (name, def = false) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
		var r = window.location.search.substr(1).match(reg); //匹配目标参数
		if (r != null) {
			return unescape(r[2]);
		} else {
			return def; //返回参数值
		}
	},
	iswechat: function () {
		return this.getUrlParam('iw', 1);
	},
	isajax: function () {
		return this.getUrlParam('ia', 1);
	},
	shareCode: function () {
		return this.getUrlParam('sc', 'a3e5g8');
	},
	shareType: function () {
		return (this.getUrlParam('st', 0) == 1) ? 'couponShare' : 'couponGeneral';
	},
	page_type: function () {
		return this.getUrlParam('tp', '200');
	},
	goodsType: function () {
		return this.getUrlParam('gt', 'data1');
	},
	debug: function () {
		return this.getUrlParam('debug', '0');
	},

	data: function () {
		return {
			data1: [
				{ "t2": "领券", "t1": "元补贴券", "image": "13", "money": "20", "code": "20", "youhui": "劵后￥46.9", "type": "某东", "typejia": "89", "xiaoliang": "9512", "title": "72小时发货 黄老五 福禄有礼盒 5袋 880g", "pp": "零食礼盒" },
				{ "t2": "领券", "t1": "元补贴券", "image": "12", "money": "40", "code": "40", "youhui": "劵后￥99", "type": "某东", "typejia": "149", "xiaoliang": "6921", "title": "72小时发货 黄老五 龙年礼礼盒 9袋 1602g", "pp": "零食礼盒" },
				{ "t2": "领券", "t1": "元补贴券", "image": "6", "money": "5", "code": "5", "youhui": "劵后￥29.9", "type": "某东", "typejia": "36.8", "xiaoliang": "6735", "title": "中冠集团 传统特产花生酥 468g", "pp": "花生酥" },
				{ "t2": "领券", "t1": "元补贴券", "image": "7", "money": "5", "code": "5", "youhui": "劵后￥29.9", "type": "某东", "typejia": "39.8", "xiaoliang": "9000", "title": "中冠集团 传统特产土麻饼 350g x2袋", "pp": "土麻饼" },
				{ "t2": "领券", "t1": "元补贴券", "image": "8", "money": "20", "code": "20", "youhui": "劵后￥69", "type": "某东", "typejia": "95", "xiaoliang": "8688", "title": "中冠集团 传统特产礼盒 4袋1050g", "pp": "零食礼盒" },
				{ "t2": "领券", "t1": "元补贴券", "image": "9", "money": "5", "code": "5", "youhui": "劵后￥34.9", "type": "某东", "typejia": "45", "xiaoliang": "6050", "title": "爱媛果冻橙 80以上精品果 2.5kg", "pp": "爱媛橙" },
				{ "t2": "领券", "t1": "元补贴券", "image": "16", "money": "20", "code": "20", "youhui": "劵后￥49.9", "type": "某东", "typejia": "69.9", "xiaoliang": "5086", "title": "正宗四川春见耙耙柑·九分甜一分酸5Kg", "pp": "耙耙柑" },
				{ "t2": "领券", "t1": "元补贴券", "image": "14", "money": "20", "code": "20", "youhui": "劵后￥59", "type": "某东", "typejia": "79.9", "xiaoliang": "6361", "title": "正宗赣南脐橙·果园直摘·八分甜二分酸 含箱10斤（净果≥9斤）", "pp": "赣南脐橙" },
				{ "t2": "领券", "t1": "元补贴券", "image": "15", "money": "20", "code": "20", "youhui": "劵后￥109", "type": "某东", "typejia": "159.9", "xiaoliang": "5733", "title": "正宗赣南脐橙·果园直摘·八分甜二分酸 含箱20斤（净果≥18斤）", "pp": "赣南脐橙" },
				{ "t2": "领券", "t1": "元补贴券", "image": "1", "money": "40", "code": "40", "youhui": "劵后￥76.9", "type": "某东", "typejia": "136", "xiaoliang": "8163", "title": "北川羌蜀味风干五花腊肉500gx2袋", "pp": "五花腊肉" },
				{ "t2": "领券", "t1": "元补贴券", "image": "2", "money": "20", "code": "20", "youhui": "劵后￥59", "type": "某东", "typejia": "79.6", "xiaoliang": "6293", "title": "北川羌蜀味麻辣香肠500gx2袋", "pp": "麻辣香肠" },
				{ "t2": "领券", "t1": "元补贴券", "image": "3", "money": "20", "code": "20", "youhui": "劵后￥79", "type": "某东", "typejia": "138", "xiaoliang": "5091", "title": "北川腊味羌蜀味羌家礼包 4袋1.02kg", "pp": "北川腊味" },
				{ "t2": "领券", "t1": "元补贴券", "image": "4", "money": "40", "code": "40", "youhui": "劵后￥95.9", "type": "某东", "typejia": "148", "xiaoliang": "8733", "title": "北川腊味羌蜀味舌尖羌味礼盒 4袋1.46kg", "pp": "北川腊味" },
				{ "t2": "领券", "t1": "元补贴券", "image": "5", "money": "40", "code": "40", "youhui": "劵后￥159", "type": "某东", "typejia": "258", "xiaoliang": "5220", "title": "羌蜀味 北川腊味礼盒 6袋1.82kg", "pp": "北川腊味" },
				{ "t2": "领券", "t1": "元补贴券", "image": "17", "money": "20", "code": "20", "youhui": "劵后￥69.9", "type": "某东", "typejia": "89.9", "xiaoliang": "8435", "title": "圣迪乐OMEGA-3营养蛋30枚 2颗满足每日营养需求", "pp": "营养蛋" },
				{ "t2": "领券", "t1": "元补贴券", "image": "10", "money": "20", "code": "20", "youhui": "劵后￥39.9", "type": "超市", "typejia": "59.9", "xiaoliang": "8644", "title": "欣涪蓉 经典麻辣火锅底料套装 1kg", "pp": "火锅底料" },
				{ "t2": "领券", "t1": "元补贴券", "image": "11", "money": "5", "code": "5", "youhui": "劵后￥29.9", "type": "超市", "typejia": "41", "xiaoliang": "9429", "title": "欣涪蓉 经典米粉套装 两袋米粉一罐萝卜干", "pp": "米粉+罐萝卜" }
			],
			data2: [
				{ "t2": "领取", "t1": "元补贴码", "image": "23", "money": "100", "code": "S00321869", "youhui": "劵后￥279", "type": "某东", "typejia": "378", "xiaoliang": "5291", "title": "长虹 1.45英寸健康监测智能手表WATCH FLY(标准版)银色【线下专柜同款】", "pp": "智能手表" },
				{ "t2": "领取", "t1": "元补贴码", "image": "24", "money": "100", "code": "S00322175", "youhui": "劵后￥279", "type": "某东", "typejia": "378", "xiaoliang": "3869", "title": "长虹 1.45英寸健康监测智能手表WATCH FLY(标准版)黑色【线下专柜同款】", "pp": "智能手表" },
				{ "t2": "领取", "t1": "元补贴码", "image": "26", "money": "20", "code": "S00336829", "youhui": "劵后￥59", "type": "某东", "typejia": "158", "xiaoliang": "9694", "title": "电吹风DCF-20A8【线下专柜同款】", "pp": "电吹风" },
				// { "t2": "领取", "t1": "元补贴码", "image": "27", "money": "100", "code": "S00336386", "youhui": "劵后￥269", "type": "某东", "typejia": "499", "xiaoliang": "9022", "title": "美菱家用踢脚线电暖MPN-DT01【线下专柜同款】", "pp": "取暖器" },
				{ "t2": "领取", "t1": "元补贴码", "image": "21", "money": "100", "code": "S00336375", "youhui": "劵后￥89", "type": "某东", "typejia": "399", "xiaoliang": "6755", "title": "长虹养生壶CHYS-15X01【线下专柜同款】", "pp": "养生壶" },
				{ "t2": "领取", "t1": "元补贴码", "image": "22", "money": "20", "code": "S00336841", "youhui": "劵后￥59", "type": "某东", "typejia": "199", "xiaoliang": "3931", "title": "长虹保温烧水壶CSH-1800LP【线下专柜同款】", "pp": "烧水壶" },
				{ "t2": "领取", "t1": "元补贴码", "image": "32", "money": "20", "code": "S00333998", "youhui": "劵后￥99", "type": "某东", "typejia": "299", "xiaoliang": "7527", "title": "美菱养生壶MJ-B516【线下专柜同款】", "pp": "养生壶" },
				{ "t2": "领取", "t1": "元补贴码", "image": "35", "money": "100", "code": "S00336657", "youhui": "劵后￥199", "type": "某东", "typejia": "449", "xiaoliang": "7774", "title": "美菱空气炸锅MZG-4501(机械款)【线下专柜同款】", "pp": "空气炸锅" },
				{ "t2": "领取", "t1": "元补贴码", "image": "25", "money": "100", "code": "S00336387", "youhui": "劵后￥149", "type": "某东", "typejia": "499", "xiaoliang": "5921", "title": "多功能电火锅JRG-15K01【线下专柜同款】", "pp": "多功能电锅" },
				{ "t2": "领取", "t1": "元补贴码", "image": "30", "money": "200", "code": "S00334096", "youhui": "劵后￥1999", "type": "某东", "typejia": "3349", "xiaoliang": "3028", "title": "美菱 按摩椅MI-D01【线下专柜同款】", "pp": "按摩椅" },
				// { "t2": "领取", "t1": "元补贴码", "image": "36", "money": "200", "code": "S00334097", "youhui": "劵后￥2999", "type": "某东", "typejia": "5599", "xiaoliang": "4842", "title": "美菱 按摩椅MI-D09【线下专柜同款】", "pp": "按摩椅" },
				// { "t2": "领取", "t1": "元补贴码", "image": "28", "money": "200", "code": "S00323356", "youhui": "劵后￥1199", "type": "某东", "typejia": "1799", "xiaoliang": "8263", "title": "美菱洗地机智能变频清洗无线多功能XM-F1【线下专柜同款】", "pp": "洗地机" },
				{ "t2": "领取", "t1": "元补贴码", "image": "34", "money": "200", "code": "S00323324", "youhui": "劵后￥999", "type": "某东", "typejia": "1499", "xiaoliang": "7400", "title": "美菱洗地机智能吸洗拖一体XM-F1-S【线下专柜同款】", "pp": "洗地机" },
				{ "t2": "领取", "t1": "元补贴码", "image": "33", "money": "100", "code": "S00323308", "youhui": "劵后￥469", "type": "某东", "typejia": "696", "xiaoliang": "3584", "title": "美菱智能烧煮茶吧机MY-TO8【线下专柜同款】", "pp": "茶吧机" },
				// { "t2": "领取", "t1": "元补贴码", "image": "29", "money": "200", "code": "S00323318", "youhui": "劵后￥599", "type": "某东", "typejia": "996", "xiaoliang": "6026", "title": "美菱智能烧煮茶吧机MY-T67【线下专柜同款】", "pp": "茶吧机" },
				// { "t2": "领取", "t1": "元补贴码", "image": "37", "money": "100", "code": "S00334087", "youhui": "劵后￥799", "type": "某东", "typejia": "1299", "xiaoliang": "8417", "title": "美菱茶吧机MY-YT922B(冰热)【线下专柜同款】", "pp": "茶吧机" },
			],
			data3: [
				{ "t2": "领券", "t1": "元补贴券", "image": "18", "money": "100", "code": "100", "youhui": "劵后￥319", "type": "某东", "typejia": "596", "xiaoliang": "2565", "title": " 72小时发货 黄老五龙年限定礼盒 一件4盒", "pp": "集采年货" },
				{ "t2": "领券", "t1": "元补贴券", "image": "19", "money": "100", "code": "100", "youhui": "劵后￥229", "type": "某东", "typejia": "534", "xiaoliang": "9464", "title": "72小时发货 黄老五福禄有礼礼盒 一件6盒", "pp": "集采年货" },
				{ "t2": "领券", "t1": "元补贴券", "image": "20", "money": "100", "code": "100", "youhui": "劵后￥348", "type": "某东", "typejia": "477.6", "xiaoliang": "9791", "title": "年货圣迪乐 谷物蛋20枚/盒 x12 绵阳主城区72小时内配送", "pp": "集采年货" },
			],
			data4: [
				{ "t2": "点击领取", "t1": "领补贴码", "image": "119", "money": " ", "code": "S00309811", "youhui": "补贴￥600+", "type": "某东", "typejia": "2999", "xiaoliang": "768", "title": "CHiQ 4K电视50Q8L[专柜同款]", "pp": "电视" },
				{ "t2": "点击领取", "t1": "领补贴码", "image": "118", "money": " ", "code": "S00165910", "youhui": "补贴￥600+", "type": "某东", "typejia": "3999", "xiaoliang": "983", "title": "CHiQ 4K电视65Q8L[专柜同款]", "pp": "电视" },
				{ "t2": "点击领取", "t1": "领补贴码", "image": "117", "money": " ", "code": "S00317035", "youhui": "补贴￥2000+", "type": "某东", "typejia": "7997", "xiaoliang": "566", "title": "CHiQ 120Hz高刷电视75Q9T[专柜同款]", "pp": "电视" },
				{ "t2": "点击领取", "t1": "领补贴码", "image": "116", "money": " ", "code": "S00317036", "youhui": "补贴￥1000+", "type": "某东", "typejia": "8597", "xiaoliang": "625", "title": "CHiQ 120Hz高刷电视85Q9T[专柜同款]", "pp": "电视" },
				{ "t2": "点击领取", "t1": "领补贴码", "image": "115", "money": " ", "code": "S00262991", "youhui": "补贴￥3000+", "type": "某东", "typejia": "12997", "xiaoliang": "718", "title": "CHiQ 120Hz全程高刷电视90Q8R MAX[专柜同款]", "pp": "电视" },
				{ "t2": "点击领取", "t1": "领补贴码", "image": "113", "money": " ", "code": "S00281307", "youhui": "补贴￥500+", "type": "某东", "typejia": "2799", "xiaoliang": "584", "title": "冰箱BCD-269WPB两门风冷[专柜同款]", "pp": "冰箱" },
				{ "t2": "点击领取", "t1": "领补贴码", "image": "114", "money": " ", "code": "S00075716", "youhui": "补贴￥500+", "type": "某东", "typejia": "2799", "xiaoliang": "970", "title": "冰箱BCD-269WPB两门风冷[专柜同款]", "pp": "冰箱" },
				{ "t2": "点击领取", "t1": "领补贴码", "image": "111", "money": " ", "code": "S00320239", "youhui": "补贴￥900+", "type": "某东", "typejia": "4999", "xiaoliang": "751", "title": "冰箱BCD-400WP9BT法式多门[专柜同款]", "pp": "冰箱" },
				{ "t2": "点击领取", "t1": "领补贴码", "image": "112", "money": " ", "code": "S00320307", "youhui": "补贴￥900+", "type": "某东", "typejia": "4999", "xiaoliang": "872", "title": "冰箱BCD-400WP9BT法式多门[专柜同款]", "pp": "冰箱" },
				{ "t2": "点击领取", "t1": "领补贴码", "image": "110", "money": " ", "code": "S00326070", "youhui": "补贴￥1000+", "type": "某东", "typejia": "8299", "xiaoliang": "793", "title": "冰箱BCD-505WP9BT法式多门[专柜同款]", "pp": "冰箱" },
				{ "t2": "点击领取", "t1": "领补贴码", "image": "108", "money": " ", "code": "S00328306", "youhui": "补贴￥500+", "type": "某东", "typejia": "9999", "xiaoliang": "534", "title": "冻鲜生系列冰箱BCD-506WP9BDZ十字[专柜同款]", "pp": "冰箱" },
				{ "t2": "点击领取", "t1": "领补贴码", "image": "109", "money": " ", "code": "S00328363", "youhui": "补贴￥500+", "type": "某东", "typejia": "9999", "xiaoliang": "875", "title": "冻鲜生系列冰箱BCD-506WP9BDZ十字[专柜同款]", "pp": "冰箱" },
				{ "t2": "点击领取", "t1": "领补贴码", "image": "105", "money": " ", "code": "S00153092", "youhui": "补贴￥500+", "type": "某东", "typejia": "3199", "xiaoliang": "592", "title": "CHiQ空调KFR-35GW/Q6C+R1全无尘[专柜同款]", "pp": "空调" },
				{ "t2": "点击领取", "t1": "领补贴码", "image": "106", "money": " ", "code": "S00153087", "youhui": "补贴￥300+", "type": "某东", "typejia": "2899", "xiaoliang": "975", "title": "CHiQ空调KFR-26GW/Q6C+R1全无尘[专柜同款]", "pp": "空调" },
				{ "t2": "点击领取", "t1": "领补贴码", "image": "103", "money": " ", "code": "S00233334", "youhui": "补贴￥1200+", "type": "某东", "typejia": "7999", "xiaoliang": "945", "title": "CHiQ空调KFR-72LW/Q6C+R1客餐柜[专柜同款]", "pp": "空调" },
				{ "t2": "点击领取", "t1": "领补贴码", "image": "102", "money": " ", "code": "S00154865", "youhui": "补贴￥1000+", "type": "某东", "typejia": "2399", "xiaoliang": "881", "title": "美菱洗衣机MB100-601GX波轮[专柜同款]", "pp": "洗衣机" },
				{ "t2": "点击领取", "t1": "领补贴码", "image": "101", "money": " ", "code": "S00265586", "youhui": "补贴￥1000+", "type": "某东", "typejia": "3599", "xiaoliang": "847", "title": "美菱洗衣机MG100-14586DHLXDD直驱[专柜同款]", "pp": "洗衣机" },
				{ "t2": "点击领取", "t1": "领补贴码", "image": "100", "money": " ", "code": "S00244159", "youhui": "补贴￥400+", "type": "某东", "typejia": "2888", "xiaoliang": "609", "title": "美菱洗衣机MG100-14596BHILX十分薄[专柜同款]", "pp": "洗衣机" }
			]
		};
	},
	// console.log(['page_type', page_type]);
	query: function () {
		return '&tp=' + this.page_type() + '&iw=' + this.iswechat() + '&ia=' + this.isajax();
	},
	//设置跳转小程序地址

	linkToOther: function (Codes, type = true) {
		if (type) {
			var query = 'activityCode=null&activityId=null&goodsId=' + Codes + '&shareType=shop&shopCode=' + this.shareCode();
			var url = 'pagesCategory/HCGoods/HCGoodsDetail&query=' + encodeURIComponent(query);
			var href = 'weixin://dl/business/?appid=wxae3c5a3987427db8&path=' + url;
			console.log('href', href);
			console.log('type:', type);
			console.log('Codes:', Codes);
			location.href = href;
		} else {
			var href = 'weixin://dl/business/?appid=wxae3c5a3987427db8&path=pagesHome/HCHome/HCWebViewcoup&query=' + encodeURIComponent('couponId=' + Codes);
			console.log(['href', href]);
			location.href = href;
		}
	},
	wxapplink: function (Codes, type = true) {
		if (type) {
			var url = '/pagesCategory/HCGoods/HCGoodsDetail?activityCode=null&activityId=null&goodsId=' + Codes + '&shareType=shop&shopCode=' + this.shareCode();
			console.log('type:', type)
			console.log('Codes:', Codes)
			console.log('url:', url)
			wx.miniProgram.navigateTo({ url: url });
		} else {
			var url = '/pagesHome/HCHome/HCWebViewcoup?couponId=' + Codes;
			console.log('type:', type)
			console.log('Codes:', Codes)
			console.log('url:', url)
			wx.miniProgram.navigateTo({ url: url });
		}

	},
	copyToClipboard: function (text) {
		var txt = ClipboardJS.copy(text);
		console.log(['已经复制内容：', txt]);


	},
	getHongCode: function (type = 'data2') {
		// 定义一个包含多个对象的数组
		if (type == 'data2') {
			var HongCodes = [
				//公会
				'41380', '37509', '24454', '71606', '63359', '21740', '38600', '53400', '51287', '32283', '62690', '52984', '67711',
				'44561', '16095', '94893', '74382', '55987', '80580', '91884', '40066', '10878', '22923', '28399', '30206', '62066',
				'81047', '90616', '47216', '95501', '24583', '37123', '10106', '25609', '22383', '57946', '10313', '21440', '15823',
				'15665', '94237', '96595', '98506', '10412', '24818', '32616', '41792', '40247',
			];

			// var HongCodes = [
			// 	//直播游仙
			// 	'95493', '11003', '75820', '24855', '12815', '94422', '31794', '94362', '69671', '46131', '16817', '46310', '72013',
			// 	'34296', '19926', '60711', '29274', '25981', '95708', '84164', '59467', '74351', '49622', '32566', '67385', '45964',
			// 	'26549', '69772', '60021', '50259', '42862', '52277', '40244', '69845', '73189', '27666', '22143', '51543', '14528',
			// 	'39809', '28696', '12368', '82710', '28176', '52878', '89273', '88172', '32536', '12021', '35402', '91940', '27200',
			// ];
		}
		if (type == 'data4') {
			var HongCodes = [
				//公会
				'20070694',
				'20405094',
				'20324757',
			];

			// var HongCodes = [
			// 	//直播游仙
			// 	'20273092',
			// 	'20186059',
			// 	'20426671',
			// ];
		}

		// 生成一个0到arr.length-1之间的随机整数作为索引
		var HongCode = Math.floor(Math.random() * HongCodes.length);

		// 根据索引获取数组中的对象
		return HongCodes[HongCode];
	},

	link: function (code) {
		console.log(['code', code])
		if (app.goodsType() == 'data2') {
			// navigator.clipboard.writeText('text');
			console.log('data2');
			// 为每个 a 标签添加点击事件
			var HongCode = this.getHongCode(app.goodsType());
			console.log(['虹码：', HongCode]);
			// alert('获取商品的虹码成功；①请在结算页面粘贴虹码再下单，享受优惠价格！');
			// 初始化对话框
			this.copyToClipboard(HongCode);

			$("#MsgId").dialog({
				title: "已生成虹码：" + HongCode,
				autoOpen: false, // 默认不显示对话框
				width: 300,  // 设置对话框宽度为300px
				height: 200, // 设置对话框高度为200px
				modal: true, // 设置对话框为模态对话框
				buttons: {   // 设置对话框按钮
					"确定": function () {
						if (app.iswechat() == 1) {
							console.log('MicroMessenger');
							app.wxapplink(code, true);
						} else {
							console.log('Other');
							app.linkToOther(code, true);
						}
						$(this).dialog("close"); // 关闭对话框
					}
				}
			});
			$("#MsgId").dialog("open");


		} else if (app.goodsType() == 'data4') {
			// navigator.clipboard.writeText('text');
			console.log('data4');
			// 为每个 a 标签添加点击事件
			var HongCode = this.getHongCode(app.goodsType());
			console.log(['虹码：', HongCode]);
			// alert('获取商品的虹码成功；①请在结算页面粘贴虹码再下单，享受优惠价格！');
			// 初始化对话框
			this.copyToClipboard(HongCode);

			$("#MsgId").dialog({
				title: "已生成虹码：" + HongCode,
				autoOpen: false, // 默认不显示对话框
				width: 300,  // 设置对话框宽度为300px
				height: 200, // 设置对话框高度为200px
				modal: true, // 设置对话框为模态对话框
				buttons: {   // 设置对话框按钮
					"确定": function () {
						if (app.iswechat() == 1) {
							console.log('MicroMessenger');
							app.wxapplink(code, true);
						} else {
							console.log('Other');
							app.linkToOther(code, true);
						}
						$(this).dialog("close"); // 关闭对话框
					}
				}
			});
			$("#MsgId").dialog("open");


		} else {
			console.log('data1、data3');

			console.log('note ajax');
			console.log('couponType', code);
			var codes = {
				'20': '1744188974546554881',
				'40': '1744189582330626049',
				'100': '1744191942788448258',
				'5': '1744291735237824513',
			};
			console.log('this.iswechat()', this.iswechat())
			if (this.iswechat() == 1) {
				console.log('MicroMessenger');
				console.log(codes[code]);
				app.wxapplink(codes[code], false);
			} else {
				console.log('Other');
				app.linkToOther(codes[code], false);
			}
		}

	},
	getPageName: function () {
		var url = window.location.href;
		var filename = url.substring(url.lastIndexOf('/') + 1);
		filename = filename.split('.')[0];
		console.log(['filename', filename]);
		return filename;
	},
	dialog: function () {
		var div = document.createElement('div');
		div.id = "MsgId";
		div.hidden = 'hidden';
		document.body.append(div);
		$("#MsgId").append("补贴码已复制成功，请在结算页面“虹码”处粘贴！");

	},
	//运行
	run: function () {
		debug();
		console.log('url:', window.location.href)
		app.dialog();
		//设置头图
		var page_list = {};
		$("#page_list").find("img").each(function () {
			page_list[$(this).data("title")] = $(this).attr("src");
		});
		console.log(['page_list', page_list]);
		console.log(['page_type', this.page_type()]);

		// $('.jq22-ad-img').html('<img src="' + page_list[this.page_type()] + '" alt="">');
		$('.jq22-ad-img').html('<img src="https://csmbimagae.shop.jzzw-tech.cn/hcyp/app1/images/000.gif" alt="">');
		// $('.jq22-ad-img').html('<img src="https://csmbimagae.shop.jzzw-tech.cn/hcyp/app1/images/' + this.page_type() + '.png" alt="">');
		//设置横向菜单
		var pageName = this.getPageName();
		var goods = [
			{ gt: 'data1', title: '年 货', query: this.query(), pageName: pageName },
			{ gt: 'data2', title: '小家电', query: this.query(), pageName: pageName },
			{ gt: 'data3', title: '集 采', query: this.query(), pageName: pageName },
			{ gt: 'data4', title: '大家电', query: this.query(), pageName: pageName },
		];
		$('.jq22-flex-one').html(template('tpl-title', goods));

		$(".jq22-flex-box").css("color", "white").css("font-size", "18px").css('background-color', 'red').css('border', '4px solid #f9afaf').css('border-radius', '12%').css('margin', '3px 1px 3px 1px').css('padding', '5px 0px 5px 0px')
		//设置商品数据
		var data = app.data();
		var goodsType = this.goodsType();

		console.log(['goodsType', goodsType]);
		//设置商品头图
		var image_list = [];
		$("#image_list").find("img").each(function (index, value) {
			image_list.push($(this).attr("src"));
		});
		console.log('image_list', image_list);

		var viewData = data[goodsType];

		var viewDatas = viewData.map(function (item, index) {
			// item.image = image_list[item.image - 1];
			item.image = 'https://csmbimagae.shop.jzzw-tech.cn/hcyp/app1/images/' + item.image + '.jpg';

			// console.log(['items', item]);
			return item;
		});

		console.log(['viewDatas', viewDatas])

		$('.jq22-ate-list').html(template('tpl-user', viewDatas));

	},
}